
<form class="well form-horizontal span8" action="<?php echo base_url() . "admin.php/distributivo/ingresodatos" ?>" method="post">
    <legend>CREAR EL DISTRIBUTIVO DE DOCENTES</legend>

    <div class="control-group">
        <label class="control-label" for="select01">PERIODO ACTUAL</label>
        <div class="controls ">
            <select name="ide_lec" class="span3">
                <?php
                foreach ($periodos as $i => $per) {
                    echo ("<option value='" . $per["ide_lec"] . "'>");
                    echo ($per["descripcion_lec"] . "</option>");
                }
                ?>
            </select>

        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="select03">CARRERAS</label>
        <div class="controls ">
            <select name="ide_car" class="span3" autofocus
                    ONCHANGE="javascript:enviar(this.options[this.selectedIndex].value, '<?php echo (base_url()) . "admin.php/distributivo/crear" ?>');">
                        <?php
                        if ($ide_car == -1)
                            echo ("<option value='-1' selected>Seleccionar Carrera</option>");
                        foreach ($carrera as $i => $car) {
                            echo ("<option value='" . $car["ide_car"] . "'");
                            echo (($ide_car == $car["ide_car"] ? " selected" : "") . ">");
                            echo ($car["nombre_car"] . "</option>");
                        }
                        ?>
            </select>

        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="select03">Lista de Pensums</label>
        <div class="controls ">
            <select id="select02" name="ide_pen" class="span3"
                    ONCHANGE="javascript:enviar1('<?php echo (base_url()) . "admin.php/distributivo/crear" ?>',
                                    '<?php echo $ide_car ?>', this.options[this.selectedIndex].value);">

                <?php
                if ($ide_pen == -1)
                    echo ("<option value='-1' selected>Seleccionar Pensum</option>");

                foreach ($pensum as $i => $pen) {

                    echo ("<option value='" . $pen["ide_pen"] . "'");
                    echo (($ide_pen == $pen["ide_pen"] ? " selected" : "") . ">");
                    echo ($pen["descripcion_pen"] . "-" . $pen["estado_pen"] . "</option>");
                }
                ?>

            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="select04">Lista de Ciclos</label>
        <div class="controls ">
            <select id="codigo_cic"  name="codigo_cic" class="span3"
                    ONCHANGE="javascript:enviar2('<?php echo (base_url()) . "admin.php/distributivo/crear" ?>',
                                    '<?php echo $ide_car ?>', '<?php echo $ide_pen ?>', this.options[this.selectedIndex].value);">
                        <?php
                        if ($codigo_cic == -1)
                            echo ("<option value='-1' selected>Seleccionar Ciclo</option>");
                        foreach ($ciclo as $i => $cic) {
                            echo ("<option value='" . $cic["ide_cic"] . "'");
                            echo (($codigo_cic == $cic["ide_cic"] ? " selected" : "") . ">");
                            echo ($cic["codigo_cic"] . "-" . $cic["nombre_cic"] . "</option>");
                        }
                        ?>

            </select>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="select02">JORNADA DE TRABAJO</label>
        <div class="controls ">
            <select name="seccion" class="span3"
                    ONCHANGE="javascript:enviar3('<?php echo (base_url()) . "admin.php/distributivo/crear" ?>',
                                    '<?php echo $ide_car ?>', '<?php echo $ide_pen ?>', '<?php echo $codigo_cic ?>',
                                    this.options[this.selectedIndex].value);">
                        <?php
                        if ($seccion == -1)
                            echo ("<option value='-1' selected>Seleccionar Seccion</option>");
                        ?>  
                <option value="1"  <?php echo (($seccion == 1 ? " selected" : " ")); ?>>DIURNO </option>
                <option value="2"  <?php echo (($seccion == 2 ? " selected" : " ")); ?>> NOCTURNO</option>
                <option value="3" <?php echo (($seccion == 3 ? " selected" : " ")); ?>>FINES DE SEMANA</option>

            </select>


        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="select03">PARALELO</label>
        <div class="controls ">
            <select name="paralelo" class="span1"
                    ONCHANGE="javascript:enviar4('<?php echo (base_url()) . "admin.php/distributivo/crear" ?>',
                                    '<?php echo $ide_car ?>', '<?php echo $ide_pen ?>', '<?php echo $codigo_cic ?>',
                                    '<?php echo $seccion ?>', this.options[this.selectedIndex].value);">
                        <?php
                        if ($paralelo == -1)
                            echo ("<option value='-1' selected>Seleccionar</option>");
                        ?>  
                <option value="A"  <?php echo (($paralelo == 'A' ? " selected" : " ")); ?>>A</option>
                <option value="B"  <?php echo (($paralelo == 'B' ? " selected" : " ")); ?>>B</option>
                <option value="C" <?php echo (($paralelo == 'C' ? " selected" : " ")); ?>>C</option>
                <option value="E" <?php echo (($paralelo == 'E' ? " selected" : " ")); ?>>E</option>

            </select>


        </div>
    </div>

    <div id="tabladistributivo" >
        <table class="table table-bordered table-striped table-condensed">
            <thead>
                <tr>
                    <th>ASIGNA</th>
                    <th>COD</th>
                    <th>NOMBRE DE LA MATERIA</th>
                    <th>CRED</th>
                    <th>ESTADO</th>
                    <th>SELECCIONAR EL DOCENTE</th>

                </tr>
            </thead>
            <tbody>
                <?php
                $nro_filas = 0;
                if (!empty($materias)) {
                    $nro_filas = count($materias);
                    foreach ($materias as $i => $mat) {
                        ?>
                        <tr>
                            <td ><div centrar align="center">
                               <input type="checkbox" <?php echo "name='ide_mat" . $i . "' value='" . $mat['ide_mat'] . "'"; ?> /></div></td>
                            <td><?php echo $mat['codigo_mat'] ?></td>
                            <td><?php echo $mat['nombre_mat'] ?></td>
                            <td><?php echo $mat['creditos_mat'] ?></td>
                            <td >
                                <select <?php
                                //echo "id='estado".$i."' ". "name='estado".$i."'";
                                echo "name='estado" . $i . "'";
                                ?> class="span1">
                                    <option value='0'>ACTIVO</option>
                                    <option value='1'>PENDIENTE</option>
                                </select>


                            </td>   
                            <td >
                                <select <?php echo "name='ide_doc" . $i . "'"; ?> class="span3">
                                    <?php
                                    foreach ($docentes as $k => $doc) {
                                        echo ("<option value='" . $doc["ide_doc"] . "'>");
                                        echo ($doc["apellido_pers"] . " " . $doc["nombre_pers"] . "</option>");
                                    }
                                    ?>

                                </select>


                            </td>                                       

                        </tr>
                        <?php
                    }
                }
                ?>
            </tbody>
        </table>        
    </div>            
    <div class="controls">
        <input type="hidden" name="nro_filas" value="<?php echo $nro_filas; ?>">
        <button type="submit" class="btn"  <?php echo (($paralelo == -1 || $seccion == -1) ? "disabled " : " "); ?>>Grabar Datos</button>
        <a href="<?php echo base_url() . "admin.php/distributivo/inicio" ?>">
            <img src="<?php echo base_url(); ?>commons/images/boton_volver.gif"></a>
    </div>



</form>
